#pragma once

// Dependencies
#include "Contour2.h"
#include "Tessellation2.h"
#include "Tessellator.h"
#include <vector>

class Polygon2 {
public: // Typedefs
	typedef std::vector<Contour2_t<double>> contour_array;

public: // Types
	struct LockContours {
		Polygon2& target;
		class Tessellator* tess;
		
		LockContours( Polygon2& ref, Tessellator* t );
		~LockContours();

		contour_array& contours();
	};

public: // Constructors
	Polygon2();

	template<class InputIterator>
	Polygon2( InputIterator begin, InputIterator end, Tessellator* t = 0 ) : mContours( begin, end ) {
		if ( t )
			t->tessellate( *this );
	}

public: // Methods
	void recalculate( Tessellator* tess );

	Point2 center() const;

public: // Mutators
	LockContours lockContours( Tessellator* t = 0 );

public: // Accessors
	const contour_array& contours() const;
	const Tessellation2& tessellation() const;

private: // Members
	contour_array mContours;
	Tessellation2 mInterior;

private: // Friends
	friend class Tessellator;
};

